<?php
$GLOBALS['error_message'] = '';
if ( isset($_REQUEST['code']) ) {
	$code = base64_decode($_REQUEST['code']);
	if ( substr($code, 0, 6) == 'email=') {
		$str_tokens = preg_split('/&/', $code);
		if ( count($str_tokens) == 2 ){
			$email = explode('=', $str_tokens[0]);
			$email = $email[1];
			$password = explode('=', $str_tokens[1]);
			$password = $password[1];
			
			$dt = new DataTable(constant('DB_TABLE_MEMBER'));
			$condition = sprintf("`email`='%s' AND `password`='%s'",Util::sql_safe($email), Util::sql_safe($password));
			$row = $dt->get_row($condition);
			if($row){
				$update_data = array('id'=>$row['id'],'status'=>'active');
				$dt->save($update_data);
			}else{
				$GLOBALS['error_message'] = 'Invalid access';
			}
		}else{
			$GLOBALS['error_message'] = 'Invalid access';
		}
	}else{
		$GLOBALS['error_message'] = 'Invalid access';
	}
}else{
	$GLOBALS['error_message'] = 'Invalid access';
}
?>